package library.holdings;

public class HoldingImpl implements Holding, Comparable {
    private String title;

    public HoldingImpl(String title) {
        setTitle(title);
    }

    public void setTitle(String title) {
        if (title == null)
            throw new IllegalArgumentException("null title");
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public String toString() {
        return "title: " + title;
    }

    public boolean equals(Object rhs) {
        if (rhs instanceof HoldingImpl) {
            HoldingImpl h = (HoldingImpl) rhs;
            return title.equals(h.title);
        }
        return false;
    }

    public int compareTo(Object rhs) {
        HoldingImpl h = (HoldingImpl) rhs;
        return title.compareTo(h.title);
    }
}
